package com.bjtech.dao.ibatis;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;
import org.ssi.dao.impl.BaseDaoSqlMapImpl;

import com.bjtech.dao.BaseProjectInfoDao;
import com.bjtech.domain.BaseProjectInfo;

/**
 * @author wf
 *
 */
@Repository(value="baseProjectInfoDao")
public class SqlMapBaseProjectInfoDao extends BaseDaoSqlMapImpl<BaseProjectInfo> implements
		BaseProjectInfoDao {

	public List selectProjNameIdList() {
		return super.getSqlMapClientTemplate().queryForList("selectProjNameIdList");
	}

	public void deleteProjectLinkedObjs(Long id) {
		super.getSqlMapClientTemplate().delete("deleteAssignMeterInfoByProjectId",id);
		super.getSqlMapClientTemplate().delete("deleteSinkInfoByProjectId",id);
		super.getSqlMapClientTemplate().delete("deleteRoomInfoByProjectId",id);
		super.getSqlMapClientTemplate().delete("deleteBuildingInfoByProjectId",id);
		super.getSqlMapClientTemplate().delete("deleteShareAreaInfoByProjectId",id);
	}

	public Map selectTjParam(Long projectId) {
		Map tjParam = new HashMap();
		//项目总面积
		BigDecimal projArea = (BigDecimal) super.getSqlMapClientTemplate().queryForObject("selectProjAreaYjInfo",projectId);
		tjParam.put("projArea", projArea);
		//使用总面积
		BigDecimal useArea = (BigDecimal) super.getSqlMapClientTemplate().queryForObject("selectUseAreaYjInfo",projectId);
		tjParam.put("useArea", useArea);
		
		//项目楼栋数量
		Long buildingNum = (Long)super.getSqlMapClientTemplate().queryForObject("selectBudilingNumTjInfo",projectId);
		tjParam.put("buildingNum", buildingNum);
		
		//项目楼栋单元数
		Long unitNum = (Long)super.getSqlMapClientTemplate().queryForObject("selectUnitNumTjInfo",projectId);
		tjParam.put("unitNum", unitNum);
		//项目分摊域数量
		Long shareAreaNum = (Long)super.getSqlMapClientTemplate().queryForObject("selectShareAreaNumTjInfo",projectId);
		tjParam.put("shareAreaNum", shareAreaNum);
		
		//项目集中器数量
		Long jzqNum = (Long)super.getSqlMapClientTemplate().queryForObject("selectJzqNumTjInfo",projectId);
		tjParam.put("jzqNum", jzqNum);
		
		//项目分配表总数量
		Long assignMeterNum = (Long)super.getSqlMapClientTemplate().queryForObject("selectAssignMeterNumTjInfo",projectId);
		tjParam.put("assignMeterNum", assignMeterNum);
		
		//小区户数
		Long roomNum = (Long)super.getSqlMapClientTemplate().queryForObject("selectRoomNumTjInfo",projectId);
		tjParam.put("roomNum", roomNum);
		
		//散热器数量
		Long srqNum = (Long)super.getSqlMapClientTemplate().queryForObject("selectSrqNumTjInfo",projectId);
		tjParam.put("srqNum", srqNum);
		
		return tjParam;
	}

	public List selectProjListByPIndex(Long pIndex) {
		List list = super.getSqlMapClientTemplate().queryForList("selectProjListByPIndex",pIndex);
		return list;
	}

}
